/**
 * @author gaopeng
 * @date 2019/12/19 9:45 下午
 */
public class Context {
    public static final OpenState OPEN_STATE = new OpenState();
    public static final CloseState CLOSE_STATE = new CloseState();
    public static final RunState RUN_STATE = new RunState();
    public static final StopState STOP_STATE = new StopState();
    private IState state;

    public IState getState() {
        return state;
    }

    public void setState(IState state) {
        this.state = state;
        this.state.setContext(this);
    }

    public void open(){
        this.state.open();
    }

    public void close(){
        this.state.close();
    }

    public void run(){
        this.state.run();
    }

    public void stop(){
        this.state.stop();
    }
}
